import GCJ_CLASS_TYPE = require('./../../common/GCJ_CLASS_TYPE');
import Serializer = require('./../base/Serializer');
var CONFIG=require('../../../../common/config');
export  = SJGHead;

/**
 *
 * @author 
 *
 */
class SJGHead extends Serializer{
    public static SJG_DOC_FLAG_SJG_T = "SJG_T";// 模版
    public static SJG_DOC_FLAG_SJG_U = "SJG_U";// 用户数据
    public static SJG_DOC_FLAG_SJG_W = "SJG_W";// 用户数据＋模版的生成结果
    
    public flag:string= SJGHead.SJG_DOC_FLAG_SJG_T; //SJG_T 模版\SJG_U 用户
    public ver: number = 1;
    public author: string = "";
    public create_time: string = "";
    public update_time: string = "";
    public name: string = "";
    public template_id: number = null; // 在flag为SJG_DOC_FLAG_SJG_U有效，表示对应的模版id
	public constructor() {
        super();
        this.ct = GCJ_CLASS_TYPE.CLASS_TYPE_SJGHead;
	}
	
    // 从json对象(注意不是json字符串)中解析
    public fromJson(jsonObj, versionId) { 
        super.fromJson( jsonObj, versionId );
        
        this.flag = jsonObj.flag;
        this.ver  = jsonObj.ver;
        this.author = jsonObj.author;
        this.create_time  = jsonObj.create_time;
        this.update_time  = jsonObj.update_time;
        this.name  = jsonObj.name;
        this.template_id  = jsonObj.template_id;
    }
    // 转成json字符串
    public toJson():string {
        // 去掉父json字符串的头尾
        var superJson = super.toJson();
        superJson = superJson.substr(1,superJson.length-2);
                        
        var ret = '{';
        ret +=superJson;
        ret +=',';
            
        ret += ('"flag":'+'"' + this.flag+'"');
        ret +=',';
        ret += ('"ver":'+  this.ver );
        ret +=',';
        ret += ('"author":'+'"' + this.author+'"');
        ret +=',';
        ret += ('"create_time":'+'"' + this.create_time+'"');
        ret +=',';
        ret += ('"update_time":'+'"' + this.update_time+'"');
        ret +=',';
        ret += ('"name":'+'"' + this.name+'"');
        if (this.template_id){ 
            ret +=',';
            ret += ('"template_id":'+  this.template_id );
        }
        ret += "}";
        return ret;
    }
//SJG_MARK_APPEND--------------------


}//SJG_MARK_END-------------------------